Docs: except with multiple exceptions parentheses not required#145848
Docs: except with multiple exceptions parentheses not required#145848nedbat merged 1 commit intopython:mainfrom
Conversation
There was a problem hiding this comment.
I prefer the old style rather than the style personally, so I don't think we should remove one for the other. The entire library is till using the old style and we won't be switching to the new style as the old one is still fine and the most common.
For the tutorial, I'd prefer that we leave it as is (as otherwise, newcomers will be confused with existing code).
There was a problem hiding this comment.
Sorry, I didn't want to close the PR. I wanted to ask for changes by telling that it is possible to use a non-parenthized form though I don't know if it has its place in the tutorial (should we advocate for multiple forms or not? the same can be said with multilines with statements where before we needed nested ones).
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
cc @hugovk @nedbat for their teaching's opinion and @pablogsal as the PEP-758's author |
|
I would write: The parentheses are not necessary, and "as a tuple" is distracting. The point of the paragraph is to show that multiple exceptions can be named, and this is the simplest way to show that. Other code may use parentheses, but I don't think that will be a stumbling block. People are used to parentheses being optional for clarity, and there are bigger things people will need to understand as they progress from simple exception examples in the tutorial to real code. |
|
I understand the reason and won't block on it |
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
As of PEP 758 the except statement doesn't require parentheses anymore for exception tuples. See: https://peps.python.org/pep-0758/
|
@picnixz I didn't want to make a style suggestion but to fix what I thought was a confusing statement: parentheses are not mandatory anymore. Just to give you a bit of context, I missed this change in 3.14 and ruff formatter insisted removing parentheses from my code and I thought it was a ruff bug. The first link I've found on Google was the tutorial page that confirmed my wrong assumption. Instead, the actual reference doc page is correct. @nedbat I made the suggested change, it looks much better thanks. |
…nGH-145848) As of PEP 758 the except statement doesn't require parentheses anymore for exception tuples. (cherry picked from commit 6d1e9ceed3e70ebc39953f5ad4f20702ffa32119) Co-authored-by: Maurizio Sambati <duilio@users.noreply.github.com> See: https://peps.python.org/pep-0758/
|
GH-145904 is a backport of this pull request to the 3.14 branch. |
…GH-145848) (#145904) Docs: except with multiple exceptions parentheses not required (GH-145848) As of PEP 758 the except statement doesn't require parentheses anymore for exception tuples. (cherry picked from commit 6d1e9ce) See: https://peps.python.org/pep-0758/ Co-authored-by: Maurizio Sambati <duilio@users.noreply.github.com>
As of PEP 758 the except statement doesn't require parentheses anymore for exception tuples.
See: https://peps.python.org/pep-0758/
📚 Documentation preview 📚: https://cpython-previews--145848.org.readthedocs.build/